<!--
 * @Descripttion: 
 * @version: @ 1.0.0
 * @Author: 朱江洲
 * @Date: 2021-11-30 10:54:11
 * @LastEditors: 朱江洲
 * @LastEditTime: 2022-06-01 15:40:51
-->
<template>
  <div>
    <el-drawer
      title="批次信息"
      :visible.sync="dialog.testedShow"
      :direction="direction"
      :with-header="false"
      size="60%"
      :modal="false"
      @close="invoiceClose"
    >
      <div class="head">
        <div class="header">
          <div class="img">
            <div><img src="@/assets/images/icon-people.png" alt="" /></div>
            <div>
              <div class="img-up">姓名</div>
              <div class="img-down">{{ drawerData.name }}</div>
            </div>
            <h3></h3>
          </div>
          <div class="btn">
            <el-button type="primary" size="default" @click="change">
              更换负责人
            </el-button>
            <el-button type="primary" size="default" @click="enterResults">
              录入成绩
            </el-button>
            <el-dropdown>
              <el-button class="el-icon-more"></el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item @click.native="PassExam">
                  考试通过
                </el-dropdown-item>
                <el-dropdown-item @click.native="FailExam">
                  考试不通过
                </el-dropdown-item>
                <el-dropdown-item @click.native="missExam">
                  缺考
                </el-dropdown-item>
                <el-dropdown-item @click.native="finishExam">
                  完结
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </div>
        <div class="footer">
          <div class="information">
            <span>考试批次</span>
            <h4>{{ drawerData.batchName }}</h4>
          </div>
          <div class="information">
            <span>考试名称</span>
            <h4>{{ drawerData.examName }}</h4>
          </div>
          <div class="information">
            <span>手机号码</span>
            <h4>{{ drawerData.phone }}</h4>
          </div>
          <div class="information">
            <span>公司名称</span>
            <h4>{{ drawerData.company }}</h4>
          </div>
        </div>
      </div>
      <div class="strip"></div>
      <div class="specific">
        <el-tabs v-model="activeName" type="border-card">
          <el-tab-pane label="基本信息" name="first">
            <div class="basics" style="margin-top: 20px">基础信息</div>
            <el-form :model="drawerData" class="flexFrom">
              <el-form-item label="联系人：">
                {{ drawerData.contacts }}
              </el-form-item>
              <el-form-item label="联系方式：">
                {{ drawerData.contactInfo }}
              </el-form-item>
              <el-form-item label="注意事项：">
                {{ drawerData.note }}
              </el-form-item>
            </el-form>
            <div class="basics" style="margin-top: 80px">系统信息</div>
            <el-form :model="drawerData" class="flexFrom">
              <el-form-item label="负责人：">
                {{ drawerData.userName }}
              </el-form-item>
              <el-form-item label="更新时间：">
                {{ drawerData.updateTime }}
              </el-form-item>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="考试情况" name="second" class="thirdTab">
            <div class="basics" style="margin-top: 20px">考试信息</div>
            <el-form :model="drawerData">
              <div class="ExamInfo">
                <div class="theoryExam">
                  <div class="theoryExam-title">理论考试</div>
                  <el-form :model="drawerData">
                    <el-form-item label="考场：">
                      {{ drawerData.theoryRoom }}
                    </el-form-item>
                    <el-form-item label="考试地点：">
                      {{ drawerData.theoryAddress }}
                    </el-form-item>
                    <el-form-item label="考试时间：">
                      {{ drawerData.theoryStartTime }}
                    </el-form-item>
                  </el-form>
                </div>
                <div class="practicalExam">
                  <div class="practicalExam-title">实操考试</div>
                  <el-form :model="drawerData">
                    <el-form-item label="考场：">
                      {{ drawerData.operationalRoom }}
                    </el-form-item>
                    <el-form-item label="考试地点：">
                      {{ drawerData.operationalAddress }}
                    </el-form-item>
                    <el-form-item label="考试时间：">
                      {{ drawerData.operationalStartTime }}
                    </el-form-item>
                  </el-form>
                </div>
              </div>
            </el-form>
            <div class="basics" style="margin-top: 80px">成绩信息</div>
            <el-form :model="drawerData" class="flexFrom">
              <el-form-item label="理论成绩：">
                {{ drawerData.theoryPerformance }}
              </el-form-item>
              <el-form-item label="实操成绩：">
                {{ drawerData.operationalPerformance }}
              </el-form-item>
            </el-form>
            <div class="basics" style="margin-top: 80px">通过情况</div>
            <el-form :model="drawerData">
              <el-form-item label="通过情况：">
                {{ drawerData.examResult | Resulttype }}
              </el-form-item>
            </el-form>
          </el-tab-pane>
             <el-tab-pane label="团队人员" name="seventh">
            <div class="team">
              <div class="team-right">
                <el-button type="primary" size="default" plain @click="addTeam">
                  添加团队成员
                </el-button>
                <el-button type="primary" size="default" plain @click="outTeam">
                  退出团队
                </el-button>
              </div>
              <div class="team-left" v-if="selShow">
                <el-button
                  type="primary"
                  size="default"
                  plain
                  :disabled="tDisabled"
                  @click="editTeam"
                >
                  编辑
                </el-button>
                <el-button
                  type="primary"
                  size="default"
                  plain
                  @click="removeTeam"
                >
                  移除
                </el-button>
              </div>
            </div>
            <el-table
              :data="teamData"
              height="3rem"
              @selection-change="teamChange"
            >
              <template slot="empty" class="emptyBg">
                <img src="@/assets/images/empty.jpg" alt="" />
              </template>
              <el-table-column type="selection" width="55"> </el-table-column>
              <el-table-column label="姓名" prop="nickName"> </el-table-column>
              <el-table-column label="部门" prop="deptName"> </el-table-column>
              <el-table-column label="团队角色">
                <template slot-scope="scope">
                  {{ scope.row.isAdmin == true ? "负责人" : "成员" }}
                </template>
              </el-table-column>
              <el-table-column label="有效时间" prop="expire">
                <template slot-scope="scope">
                  {{ scope.row.expire == null ? "不限" : scope.row.expire }}
                </template>
              </el-table-column>
              <el-table-column label="权限">
                <template slot-scope="scope">
                  {{
                    scope.row.isAdmin == true
                      ? "负责人"
                      : scope.row.readonly == 0
                      ? "读写"
                      : "只读"
                  }}
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="操作记录" name="third" class="thirdTab">
            <div
              class="operation"
              v-for="(item, index) in Operation"
              :key="index"
            >
              <div class="user">
                <div class="portrait">
                  <img :src="item.avatar" alt="" />
                </div>
                <el-tooltip
                  class="item"
                  effect="dark"
                  :content="item.createBy"
                  placement="top"
                >
                  <div class="name">{{ item.createBy }}</div>
                </el-tooltip>
              </div>
              <div class="record">
                <div class="time">{{ item.createTime }}</div>
                <div class="content">
                  <div>{{ item.content }}</div>
                </div>
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-drawer>
       <edit-user
      :dialog="dialog"
      :teamForm="teamForm"
      v-if="dialog.editTeamShowEject"
    ></edit-user>
  </div>
</template>

<script>
import { OperationRecord } from "@/api/currency";
import { teamList, deleteTeam, withdrawTeam } from "@/api/team";
import EditUser from "@/components/joinTeam/editUser.vue";
export default {
  components: {
   EditUser
  },
  props: {
    dialog: {
      type: Object,
      required: true,
    },
    drawerData: {
      type: Object,
      required: true,
    },
  },
  filters: {
    Resulttype: function (val) {
      if (val == 1) {
        val = "未通过";
      } else if (val == 2) {
        val = "通过";
      }
      return val;
    },
  },
  data() {
    return {
      teamIds: [],
      teamForm: {},
      selShow: false,
      tDisabled: true,
      teamMul: [],
      teamData: [],
      Operation: [],
      activeName: "first",
      direction: "rtl",
    };
  },
  created() {
    this.getRecord();
    this.getTeamList();
  },
  methods: {
    // 退出团队
    outTeam() {
      withdrawTeam({
        module: 23,
        entity: this.drawerData.id,
        userId: this.drawerData.userId,
      }).then((res) => {
        this.$message.success(res.msg);
        this.getTeamList();
      });
    },
    // 移除团队成员
    removeTeam() {
      deleteTeam({
        userId: this.drawerData.userId,
        ids: this.teamIds,
      }).then((res) => {
        this.$message.success(res.msg);
        this.getTeamList();
      });
    },
    // 编辑团队列表
    editTeam() {
      this.dialog.editTeamShowEject = true;
      this.$nextTick(function () {
        this.dialog.editTeamShow = true;
      });
    },
    // 团队列表选中
    teamChange(val) {
      this.teamMul = val;
      this.teamIds = [];
      if (val.length !== 0) {
        this.selShow = true;
        this.teamForm = val[0];
        val.forEach((item) => {
          this.teamIds.push(item.id);
        });
      } else {
        this.selShow = false;
      }
      if (val.length > 1) {
        this.tDisabled = true;
      } else {
        this.tDisabled = false;
      }
    },
    // 添加团队成员
    addTeam() {
      this.$parent.entities.push(this.drawerData.id);
      this.$parent.addTeam();
    },
    // 获取团队成员
    getTeamList() {
      teamList({
        module: 23,
        entity: this.drawerData.id,
        userId: this.drawerData.userId,
      }).then((res) => {
        this.teamData = res.data;
      });
    },
    // 录入成绩
    enterResults() {
      this.$parent.enterResults();
      this.$parent.achievementForm.id = this.drawerData.id;
    },
    // 更换负责人
    change() {
      this.$parent.Change();
      this.$parent.chargeId = this.drawerData.id;
    },
    // 完结
    finishExam() {
      this.$parent.ids = [];
      this.$parent.ids.push(this.drawerData.id);
      this.$parent.finishExam();
    },
    // 缺考
    missExam() {
      this.$parent.ids = [];
      this.$parent.ids.push(this.drawerData.id);
      this.$parent.missExam();
    },
    // 考试不通过
    FailExam() {
      this.$parent.ids = [];
      this.$parent.ids.push(this.drawerData.id);
      this.$parent.FailExam();
    },
    // 通过
    PassExam() {
      this.$parent.ids = [];
      this.$parent.ids.push(this.drawerData.id);
      this.$parent.PassExam();
    },

    invoiceClose() {
      this.dialog.testedShowEject = false;
    },
    // 获取操作记录
    getRecord() {
      OperationRecord({ columnId: 23, entryId: this.drawerData.id }).then(
        (res) => {
          this.Operation = res.data;
        }
      );
    },
  },
};
</script>

<style lang="less" scoped>
.head {
  padding: 29px;
  width: 100%;
  height: 155px;
  border-bottom: 1px solid #ececec;
  span {
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #999999;
  }
  .header {
    display: flex;
    justify-content: space-between;
    .img {
      display: flex;
      transform: translateY(-15px);
      .img-up {
        font-size: 12px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #999999;
      }
      .img-down {
        font-size: 14px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #2b2b2b;
      }
      img {
        width: 40px;
        height: 40px;
        vertical-align: middle;
        margin-right: 12px;
      }
      h3 {
        display: inline-block;
      }
    }
  }
  .footer {
    display: flex;
    .information {
      display: flex;
      flex-direction: column;
      margin-right: 80px;
      h4 {
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #2b2b2b;
        margin-top: 12px;
      }
    }
  }
}
.strip {
  width: 100%;
  height: 16px;
  background: #fafafa;
  border: 1px solid #ececec;
  /deep/.el-tabs__nav-scroll {
    background-color: #f5f8fa;
  }
}

/deep/ .el-tab-pane {
  padding-left: 24px;
}
.basics {
  position: relative;
  font-size: 14px;
}
.basics::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 1px;
  width: 3px;
  height: 14px;
  background: #1267fa;
}

.system {
  margin-top: 30px;
  position: relative;
  font-size: 14px;
}
.system::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 1px;
  width: 3px;
  height: 14px;
  background: #1267fa;
}
.basics-information {
  display: flex;
  flex-wrap: wrap;
  .subclass {
    width: 360px;
    margin-top: 30px;
    margin-right: 150px;
    span {
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #999999;
      line-height: 14px;
      vertical-align: top;
    }
    img {
      width: 200px;
      height: 200px;
    }
  }
}

.el-dropdown {
  margin-left: 10px;
}
/deep/.thirdTab {
  .el-tabs__content {
    height: 100vh;
  }
}
/deep/.el-table__header-wrapper {
  background: #f2f2f2;
}
.el-tab-pane {
  height: 73vh;
  overflow: auto;
}
.operation {
  display: flex;
  .user {
    display: flex;
    .portrait {
      width: 30px;
      height: 30px;
      border-radius: 30px;
      img {
        width: 100%;
        height: 100%;
        border-radius: 30px;
      }
    }
    .name {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      width: 100px;
      height: 30px;
      line-height: 30px;
      margin-left: 14px;
    }
  }
  .record {
    padding-left: 21px;
    margin-left: 44px;
    border-left: 1px dotted #dbdcdb;
    .time {
      font-size: 14px;
      position: relative;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #999999;
      line-height: 14px;
    }
    .time::before {
      content: "";
      position: absolute;
      left: -27px;
      width: 11px;
      height: 11px;
      background-color: #000;
      transform: rotate(45deg);
    }
    .content {
      padding-top: 10px;
      padding-bottom: 10px;
    }
  }
}
.cell {
  img {
    width: 40px;
    height: 40px;
  }
}
.previewImg {
  img {
    width: 100%;
    height: 100%;
  }
}
.downLoad {
  a {
    color: #1267fa !important;
    font-size: 12px;
  }
}
.flexFrom {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  .el-form-item {
    width: 50%;
  }
}
.ExamInfo {
  display: flex;
  width: 100%;
  .el-form {
    margin-left: 20px;
  }
  .theoryExam {
    margin-left: 20px;
    margin-top: 20px;
    width: 50%;
    .theoryExam-title {
      font-size: 18px;
      font-weight: 500;
    }
    /deep/ .el-form-item:nth-child(1) {
      margin-top: 20px;
    }
  }
  .practicalExam {
    margin-left: 20px;
    margin-top: 20px;
    width: 50%;
    .practicalExam-title {
      font-size: 18px;
      font-weight: 500;
    }
    /deep/ .el-form-item:nth-child(1) {
      margin-top: 20px;
    }
  }
}
/deep/.el-form-item__label {
  width: 100px;
}
.team {
  display: flex;
  justify-content: space-between;
}
</style>